<?php
/**
 * Created by PhpStorm.
 * User: CodeShuhao
 * Date: 2019/6/9
 * Time: 11:10
 */

namespace app\common\model;


use think\Model;


abstract class BasicModel extends Model
{
    protected $_map = null;

    public function __construct($data = [])
    {
        parent::__construct($data);
    }

    /**
     * 字段属性映射
     * @param array $data
     * @return array
     */
    protected function attributeMap($data = [])
    {
        if ( empty($data) )
        {
            return $data;
        }

        foreach ( $this->_map as $key => $value )
        {
            if ( isset($value) && isset($data[$key]) )
            {
                $data[$key.'_map'] = $value[$data[$key]];
            }
        }

        return $data;
    }
}